<?php

namespace App\Caches;

use App\Services\PhoneCodeService;
use YQ\YqExtend;

class PhoneCodeCache extends CacheBase
{
    /**
     * 缓存前缀
     * @var string
     */
    protected $prefix = 'phoneCode';

    protected $minutes = 5;  //验证码缓存5分钟

    /**
     * 读取真实数据，此接口只能由 remember 来回调
     * @param string|array $keys 检索key
     * @return string|array|integer
     */
    protected function getReal($key = '')
    {
        return [
            'code'    => YqExtend::getRandomInt(PhoneCodeService::PHONE_CODE_LENGTH),
            'created' => time(),
        ];
    }
}
